<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function deepClone(obj) {
        if (typeof obj !== "object" || obj === null) {
          return obj;
        }
        let copy = Array.isArray(obj) ? [] : {};
        Object.keys(obj).forEach((keys) => {
          copy[keys] = deepClone(obj[keys]);
        });
        return copy;
      }
      // my feature
      const obj = {
        name: "John",
        age: 30,
        address: {
          city: "New York",
          country: "USA",
        },
        hobbies: ["reading", "swimming", "traveling"],
      };

      const copy = deepClone(obj);

      console.log(copy); // { name: 'John', age: 30, address: { city: 'New York', country: 'USA' }, hobbies: [ 'reading', 'swimming', 'traveling' ] }
      console.log(copy === obj); // false
      console.log(copy.address === obj.address); // false
      console.log(copy.hobbies === obj.hobbies); // false
    </script>
  </body>
</html>
